package com.sweet.mealon.face.daily.lock.concurence.cyclicBarrier;

import java.util.concurrent.CyclicBarrier;

/**
 * faceDaily
 *
 * @Author: craizer.huang
 * @Date: 2021/5/1 14:22
 **/
public class CyclicBarrierDemo {

    public static void main(String[] args) {
        CyclicBarrier cyclicBarrier = new CyclicBarrier(10, new Runnable() {
            public void run() {
                System.out.println(String.format("%s 完成最后任务",Thread.currentThread().getName()));
            }
        });
        for (int i = 0; i < 10; i++) {
            Thread t = new Thread(new CyclicBarrierThread(cyclicBarrier));
            t.start();
        }
    }
}
